/*
	Copyright (C) 2009 jungil Han <jungil.Han@gmail.com>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "mkPopupMenu.h"
#include "../Button/mkHotkeyButton.h"

#include <QAction>

mkPopupMenu::mkPopupMenu( QWidget *a_pParent ) : mkMenu( a_pParent )
{
	m_pOpenAction = new QAction( tr("Open &File"), this );
	connect(m_pOpenAction, SIGNAL( triggered() ), static_cast<mkHotkeyButton *>( parent() ), SLOT( SlotFileOpenClicked() ));

	m_pURLAction = new QAction( tr("Open &URL"), this );
	connect(m_pURLAction, SIGNAL( triggered() ), static_cast<mkHotkeyButton *>( parent() ), SLOT( SlotURLClicked() ));

	m_pConfigAction = new QAction( tr("&Config Hotkey"), this );
	m_pConfigAction->setVisible( false );	/* default attribute is hide */
	connect(m_pConfigAction, SIGNAL( triggered() ), static_cast<mkHotkeyButton *>( parent() ), SLOT( SlotConfigClicked() ));

	m_pDeleteAction = new QAction( tr("&Delete"), this );
	m_pDeleteAction->setVisible( false );	/* default attribute is hide */
	connect(m_pDeleteAction, SIGNAL( triggered() ), static_cast<mkHotkeyButton *>( parent() ), SLOT( SlotDeleteClicked() ));

	addAction( m_pOpenAction );
	addAction( m_pURLAction );
	addSeparator();
	addAction( m_pConfigAction );
	addAction( m_pDeleteAction );
}

mkPopupMenu::~mkPopupMenu()
{
	MK_DELETE( m_pOpenAction );
	MK_DELETE( m_pURLAction );
	MK_DELETE( m_pConfigAction );
	MK_DELETE( m_pDeleteAction );
}

void mkPopupMenu::SetVisibleAction( IN eACTION_TYPE a_eType, IN bool a_bVisible )
{
	switch ( a_eType ) {
	case eOpenFile:
		m_pOpenAction->setVisible( a_bVisible );
		break;
	case eOpenURL:
		m_pURLAction->setVisible( a_bVisible );
		break;
	case eConfig:
		m_pConfigAction->setVisible( a_bVisible );
		break;
	case eDelete:
		m_pDeleteAction->setVisible( a_bVisible );
		break;
	}
}
